.class public Lcom/brixd/niceapp/service/StatisticsService;
.super Ljava/lang/Object;
.source "StatisticsService.java"


# static fields
.field private static mContext:Landroid/content/Context;

.field private static mDaoSession:Lcom/brixd/niceapp/db/DaoSession;

.field private static mInstance:Lcom/brixd/niceapp/service/StatisticsService;

.field private static statisticsEntityDao:Lcom/brixd/niceapp/db/StatisticsEntityDao;


# direct methods
.method private constructor <init>(Landroid/content/Context;)V
    .registers 8
    .param p1, "context"    # Landroid/content/Context;

    .prologue
    .line 32
    invoke-direct {p0}, Ljava/lang/Object;-><init>()V

    .line 33
    sput-object p1, Lcom/brixd/niceapp/service/StatisticsService;->mContext:Landroid/content/Context;

    .line 34
    new-instance v2, Lcom/brixd/niceapp/db/DatabaseOpenHelper;

    sget-object v3, Lcom/brixd/niceapp/service/StatisticsService;->mContext:Landroid/content/Context;

    const-string v4, "zuimei.sqlite"

    const/4 v5, 0x0

    invoke-direct {v2, v3, v4, v5}, Lcom/brixd/niceapp/db/DatabaseOpenHelper;-><init>(Landroid/content/Context;Ljava/lang/String;Landroid/database/sqlite/SQLiteDatabase$CursorFactory;)V

    .line 35
    .local v2, "helper":Lcom/brixd/niceapp/db/DaoMaster$OpenHelper;
    invoke-virtual {v2}, Lcom/brixd/niceapp/db/DaoMaster$OpenHelper;->getWritableDatabase()Landroid/database/sqlite/SQLiteDatabase;

    move-result-object v1

    .line 36
    .local v1, "db":Landroid/database/sqlite/SQLiteDatabase;
    new-instance v0, Lcom/brixd/niceapp/db/DaoMaster;

    invoke-direct {v0, v1}, Lcom/brixd/niceapp/db/DaoMaster;-><init>(Landroid/database/sqlite/SQLiteDatabase;)V

    .line 37
    .local v0, "daoMaster":Lcom/brixd/niceapp/db/DaoMaster;
    invoke-virtual {v0}, Lcom/brixd/niceapp/db/DaoMaster;->newSession()Lcom/brixd/niceapp/db/DaoSession;

    move-result-object v3

    sput-object v3, Lcom/brixd/niceapp/service/StatisticsService;->mDaoSession:Lcom/brixd/niceapp/db/DaoSession;

    .line 38
    sget-object v3, Lcom/brixd/niceapp/service/StatisticsService;->mDaoSession:Lcom/brixd/niceapp/db/DaoSession;

    invoke-virtual {v3}, Lcom/brixd/niceapp/db/DaoSession;->getStatisticsEntityDao()Lcom/brixd/niceapp/db/StatisticsEntityDao;

    move-result-object v3

    sput-object v3, Lcom/brixd/niceapp/service/StatisticsService;->statisticsEntityDao:Lcom/brixd/niceapp/db/StatisticsEntityDao;

    .line 39
    return-void
.end method

.method public static addFailedLog(Ljava/lang/String;)J
    .registers 5
    .param p0, "logInfo"    # Ljava/lang/String;

    .prologue
    .line 96
    sget-object v1, Lcom/brixd/niceapp/service/StatisticsService;->mContext:Landroid/content/Context;

    const-string v2, "ZMLogSendFailed"

    invoke-static {v1, v2}, Lcom/umeng/analytics/MobclickAgent;->onEvent(Landroid/content/Context;Ljava/lang/String;)V

    .line 97
    new-instance v0, Lcom/brixd/niceapp/db/StatisticsEntity;

    invoke-direct {v0}, Lcom/brixd/niceapp/db/StatisticsEntity;-><init>()V

    .line 98
    .local v0, "entity":Lcom/brixd/niceapp/db/StatisticsEntity;
    invoke-virtual {v0, p0}, Lcom/brixd/niceapp/db/StatisticsEntity;->setLogJson(Ljava/lang/String;)V

    .line 99
    sget-object v1, Lcom/brixd/niceapp/service/StatisticsService;->statisticsEntityDao:Lcom/brixd/niceapp/db/StatisticsEntityDao;

    invoke-virtual {v1, v0}, Lcom/brixd/niceapp/db/StatisticsEntityDao;->insert(Ljava/lang/Object;)J

    move-result-wide v2

    return-wide v2
.end method

.method public static getAllFailedLogs()Ljava/util/List;
    .registers 1
    .annotation system Ldalvik/annotation/Signature;
        value = {
            "()",
            "Ljava/util/List",
            "<",
            "Lcom/brixd/niceapp/db/StatisticsEntity;",
            ">;"
        }
    .end annotation

    .prologue
    .line 114
    sget-object v0, Lcom/brixd/niceapp/service/StatisticsService;->statisticsEntityDao:Lcom/brixd/niceapp/db/StatisticsEntityDao;

    invoke-virtual {v0}, Lcom/brixd/niceapp/db/StatisticsEntityDao;->queryBuilder()Lde/greenrobot/dao/query/QueryBuilder;

    move-result-object v0

    invoke-virtual {v0}, Lde/greenrobot/dao/query/QueryBuilder;->list()Ljava/util/List;

    move-result-object v0

    return-object v0
.end method

.method public static getApplicationContext()Landroid/content/Context;
    .registers 1

    .prologue
    .line 56
    sget-object v0, Lcom/brixd/niceapp/service/StatisticsService;->mContext:Landroid/content/Context;

    return-object v0
.end method

.method public static initialize(Landroid/content/Context;)V
    .registers 3
    .param p0, "context"    # Landroid/content/Context;

    .prologue
    .line 46
    sget-object v0, Lcom/brixd/niceapp/service/StatisticsService;->mInstance:Lcom/brixd/niceapp/service/StatisticsService;

    if-nez v0, :cond_13

    .line 47
    const-class v1, Lcom/brixd/niceapp/service/StatisticsService;

    monitor-enter v1

    .line 48
    :try_start_7
    sget-object v0, Lcom/brixd/niceapp/service/StatisticsService;->mInstance:Lcom/brixd/niceapp/service/StatisticsService;

    if-nez v0, :cond_12

    .line 49
    new-instance v0, Lcom/brixd/niceapp/service/StatisticsService;

    invoke-direct {v0, p0}, Lcom/brixd/niceapp/service/StatisticsService;-><init>(Landroid/content/Context;)V

    sput-object v0, Lcom/brixd/niceapp/service/StatisticsService;->mInstance:Lcom/brixd/niceapp/service/StatisticsService;

    .line 51
    :cond_12
    monitor-exit v1

    .line 53
    :cond_13
    return-void

    .line 51
    :catchall_14
    move-exception v0

    monitor-exit v1
    :try_end_16
    .catchall {:try_start_7 .. :try_end_16} :catchall_14

    throw v0
.end method

.method public static logFailedInfo(Lcom/brixd/niceapp/db/StatisticsEntity;Lcom/brixd/niceapp/model/Token;)V
    .registers 9
    .param p0, "statisticsEntity"    # Lcom/brixd/niceapp/db/StatisticsEntity;
    .param p1, "token"    # Lcom/brixd/niceapp/model/Token;

    .prologue
    .line 76
    sget-object v1, Lcom/brixd/niceapp/service/StatisticsService;->mContext:Landroid/content/Context;

    invoke-static {v1}, Lcom/brixd/niceapp/service/adapter/ReqRestAdapter;->niceAppAdapter(Landroid/content/Context;)Lretrofit/RestAdapter;

    move-result-object v1

    const-class v2, Lcom/brixd/niceapp/service/restful/StatisticsRestfulRequest;

    invoke-virtual {v1, v2}, Lretrofit/RestAdapter;->create(Ljava/lang/Class;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/brixd/niceapp/service/restful/StatisticsRestfulRequest;

    .line 77
    .local v0, "mLogRestfulRequest":Lcom/brixd/niceapp/service/restful/StatisticsRestfulRequest;
    invoke-virtual {p0}, Lcom/brixd/niceapp/db/StatisticsEntity;->getLogJson()Ljava/lang/String;

    move-result-object v1

    invoke-virtual {p1}, Lcom/brixd/niceapp/model/Token;->getTimestamp()J

    move-result-wide v2

    invoke-virtual {p1}, Lcom/brixd/niceapp/model/Token;->getUid()I

    move-result v4

    invoke-virtual {p1}, Lcom/brixd/niceapp/model/Token;->getSecr()Ljava/lang/String;

    move-result-object v5

    new-instance v6, Lcom/brixd/niceapp/service/StatisticsService$2;

    invoke-direct {v6, p0}, Lcom/brixd/niceapp/service/StatisticsService$2;-><init>(Lcom/brixd/niceapp/db/StatisticsEntity;)V

    invoke-interface/range {v0 .. v6}, Lcom/brixd/niceapp/service/restful/StatisticsRestfulRequest;->logDownload(Ljava/lang/String;JILjava/lang/String;Lretrofit/Callback;)V

    .line 89
    return-void
.end method

.method public static logInfo(Ljava/lang/String;Lcom/brixd/niceapp/model/Token;)V
    .registers 9
    .param p0, "logInfo"    # Ljava/lang/String;
    .param p1, "token"    # Lcom/brixd/niceapp/model/Token;

    .prologue
    .line 60
    sget-object v1, Lcom/brixd/niceapp/service/StatisticsService;->mContext:Landroid/content/Context;

    invoke-static {v1}, Lcom/brixd/niceapp/service/adapter/ReqRestAdapter;->niceAppAdapter(Landroid/content/Context;)Lretrofit/RestAdapter;

    move-result-object v1

    const-class v2, Lcom/brixd/niceapp/service/restful/StatisticsRestfulRequest;

    invoke-virtual {v1, v2}, Lretrofit/RestAdapter;->create(Ljava/lang/Class;)Ljava/lang/Object;

    move-result-object v0

    check-cast v0, Lcom/brixd/niceapp/service/restful/StatisticsRestfulRequest;

    .line 61
    .local v0, "mLogRestfulRequest":Lcom/brixd/niceapp/service/restful/StatisticsRestfulRequest;
    invoke-virtual {p1}, Lcom/brixd/niceapp/model/Token;->getTimestamp()J

    move-result-wide v2

    invoke-virtual {p1}, Lcom/brixd/niceapp/model/Token;->getUid()I

    move-result v4

    invoke-virtual {p1}, Lcom/brixd/niceapp/model/Token;->getSecr()Ljava/lang/String;

    move-result-object v5

    new-instance v6, Lcom/brixd/niceapp/service/StatisticsService$1;

    invoke-direct {v6, p0}, Lcom/brixd/niceapp/service/StatisticsService$1;-><init>(Ljava/lang/String;)V

    move-object v1, p0

    invoke-interface/range {v0 .. v6}, Lcom/brixd/niceapp/service/restful/StatisticsRestfulRequest;->logDownload(Ljava/lang/String;JILjava/lang/String;Lretrofit/Callback;)V

    .line 73
    return-void
.end method

.method public static removeFailedLog(J)V
    .registers 4
    .param p0, "key"    # J

    .prologue
    .line 110
    sget-object v0, Lcom/brixd/niceapp/service/StatisticsService;->statisticsEntityDao:Lcom/brixd/niceapp/db/StatisticsEntityDao;

    invoke-static {p0, p1}, Ljava/lang/Long;->valueOf(J)Ljava/lang/Long;

    move-result-object v1

    invoke-virtual {v0, v1}, Lcom/brixd/niceapp/db/StatisticsEntityDao;->deleteByKey(Ljava/lang/Object;)V

    .line 111
    return-void
.end method
